/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.comandos.visit;

import br.ufc.quixada.adrs.interfaces.Comando;
import br.ufc.quixada.adrs.model.Adrs;
import br.ufc.quixada.adrs.service.AdrsService;
import br.ufc.quixada.adrs.service.ProdutorService;
import java.util.Collections;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author ismaily
 */
public class CmdVisitVisualizarAdrs implements Comando {

    public String executa(HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession(true);
        Adrs adrs = new AdrsService().getAdrsById(Long.parseLong(request.getParameter("id")));

        Collections.sort(adrs.getProdutores(), ProdutorService.comparadorPorNome);
        session.setAttribute("DadosAdrs", adrs);
        return "/visit/visit_visualizar_adrs.jsp";
    }
}
